#!/bin/bash

# 找出./list中字符集是C的实例，是C的话就记录到./need_change.txt中
> ./need_change.txt
IFS=$'\n\n'
for i in `cat ./list.txt`
do
    ip=`echo $i|awk '{print $1}'`
    user=`echo $i | awk '{print $2}'`
    password=`echo $i | awk '{print $3}'`

    # 取LC_ALL的值（需要手动输入密码）
    echo $password
    char=`ssh ${user}@${ip} "echo $LC_ALL"`

    # 如果字符集为C，则需要重启agent，否则不需要重启agent
    if [ "${char}x" == Cx ];then
        echo "${ip} need change ---------character set:${char}---------" >> ./need_change.txt
    else
        echo "${ip} not change ---------character set:${char}---------" >> ./not_need_change.txt
    fi
done